package com.itcast.yygh.hosp.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itcast.common.exception.YyghException;
import com.itcast.yygh.hosp.mapper.HospSetMapper;
import com.itcast.yygh.hosp.service.HospSetService;
import com.itcast.yygh.model.model.hosp.HospitalSet;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HospSetServiceImpl extends ServiceImpl<HospSetMapper, HospitalSet> implements HospSetService {

    @Override
    public String getSignKey(String hoscode) {
        HospitalSet hospitalSet = this.getByHoscode(hoscode);
        if(null == hospitalSet) {
            throw new YyghException(20001,"失败");
        }
        return hospitalSet.getSignKey();
    }
    /**
     * 根据hoscode获取医院设置
     * @param hoscode
     * @return
     */
    private HospitalSet getByHoscode(String hoscode) {
        return baseMapper.selectOne(new QueryWrapper<HospitalSet>().eq("hoscode", hoscode));
    }
}
